Consider the English sentence
We went to that Indian restaurant in the evening because of the spicy food.
This sentence is not topicalized. Now consider it coming up in a lengthy dialogue as an answer. You may want to topicalize it to indicate the person that you picked up one of their lines.
What did you do later? — In the evening, we went to that Indian restaurant because of the spicy food.
You like it spicy, don't you? — Because of the spicy food, we went to that Indian restaurant in the evening.
Why Indian? — To that Indian restaurant, we went in the evening because of the spicy food.
And it's the same in German. But for a slight difference. All German main clauses are topicalized by default. We put the topic in front of the V2 verb instead of into a tiny extra clause in front.
Was habt ihr danach gemacht? — Am Abend sind wir wegen des scharfen Essens in dieses indische Restaurant gegangen.
Du magst es doch scharf, oder? — Wegen des scharfen Essens sind wir am Abend in dieses indische Restaurant gegangen.
Warum indisch? — In dieses indische Restaurant sind wir am Abend wegen des scharfen Essens gegangen.
But you may see a problem with that German scheme. Unlike in English, there's no way to tell apart a non-topicalized main clause from one that has the subject as its topic:
Wir sind am Abend wegen des scharfen Essens in dieses indische Restaurant gegangen.
This may be both. It depends on context how much that subject in front may be seen as the topic. It's best to assume it is indeed the topic.
If you want to spare the topic at all, you have to put some filler in there. This is often an es that does not mean anything. It's an expletive, similar to English it in phrases as It rains.
But es does not always fit. Another often used expletive is da which translates to there but more often, it's just a filler for the topic position:
Da sind wir am Abend wegen des scharfen Essens in dieses indische Restaurant gegangen.
All that given, German allows dropping the topic. But it's colloquial. That's why the common answer on the question:
Hast du deine Hausaufgaben gemacht?
is
Hab ich!
and not
Ich hab(e)!
The non-colloquial way to say this is:
Das habe ich.
or
Ich habe sie gemacht.
The rules for that topic-drop are very opaque. It's best to remember common phrases as Hab ich! and carefully listen to native speakers as they drop their topics. This is also true for finding out which expletive to use in written German.