It's quite straightforward really and mainly a class thing.
Dinner is the main meal of the day.
Lunch, or luncheon, is a meal eaten at midday.
Tea is a meal eaten in the afternoon or evening.
Traditionally, poorer people ate their main meal in the middle of the day: having 'dinner' and then having a lighter meal, 'tea', in the evening.
Richer folk would have their main banquet in the evening, possibly with guests round, and so that was their "dinner". They might take a lighter 'lunch' around noon.