I am an Indian passport holder travelling to Germany via Seoul and would like to stay in Seoul for a couple of days. I have my flight tickets to Germany and a German residence permit.
Do I need a visa to enter Seoul (via Incheon Airport)?
Let's ask Timatic, because that's what your airline will do when they decide whether you need a visa before they let you fly:
Visa required, except for Passengers with a visa issued by Australia, Canada, New Zealand or USA to nationals of India, only if in transit through Korea (Rep.): For details, click here
There is a another special exemption for Jeju Island, but that doesn't apply to you.
The rules are further explained on this website, operated by Korean Immigration.
In short, you will need a visa unless you hold a valid visa or residence permit in one of U.S. Japan, Canada, Australia, or New Zealand and are traveling through Korea for transit to/from one of those countries. If your trip starts in India, you would not qualify.
Or you could be exempt if you qualify for this: "Those who have visited Korea more than 4 times in recent two years, or those who have visited Korea more than 10 times in total can enter Korea without a Korean visa, notwithstanding the requirements above"
If you do not qualify for one of these exemptions, you will need to apply for a visa.