Of course! And Allah sw knows best.
Do you know the difference between Ar-Rahman and Ar-Raheem? Scholars have defined the difference as follows: Ar-Rahman is Allah sw mercy upon ALL His creatures, from muslims to kafirs to animals to plants. Ar-Raheem is Allah sw mercy kept specially ONLY for the Muslims. So based upon this information, Allah sw does answer the prayers of the people who do bad things. Thats one.
Second, if people never done any 'bad things', then Allah sw would wipe such people from the face of the earth and replace them with people who would do bad things then ask for His forgiveness as not committing any bad things is a sign of perfection and we all know perfection is non but Allah sw attribute. Besides Allah sw loves to forgive but people must not abuse this as Allah sw is not afraid of punishing either.
Allah sw knows best.