For example...
(Tauba 9:114)” This verses show that the Prophets used to promise and give glad tidings to the sinners just as Ibrahim too had given such glad tidings to Azar. But when he saw him persisting in idol-worshiping, he stopped from seeking forgiveness for him because, one of the conditions for acceptance of prayers is that the person for whom the forgiveness is sought should be a monotheist and not a polytheist. (3).
Allah commands a group of sinful believers to approach the Holy Prophet (s) for seeking forgiveness from Allah and to request the Prophet (s) to seek forgiveness on their behalf and if the Prophet (s) seeks forgiveness for them, then Allah would forgive their sins.
(Nisa 4:64)” Which verse can be clearer than this one where Allah orders the sinful ummah to approach the Holy Prophet (s) for acquiring the forgiveness of Allah and requesting him to pray for them?
Going to the Holy Prophet (s) and asking for forgiveness has two obvious benefits: (A) Requesting for forgiveness from the Holy Prophet (s) enlivens the essence of obedience to the Prophet in sinful persons and due to their feeling of the Holy Prophet's position, they will sincerely follow and obey the Holy Prophet (s).
Basically, such goings and comings creates a special state of humility in a person towards the Holy Prophet (s) and prepares him to sincerely act upon the verse of: أطيعوا الله وأطيعوا الرسول “Obey Allah and obey the Apostle.