Generic medicines are more affordable not because there is a significant difference in their effectiveness, but because companies have been able to reduce unnecessary costs that do not add value to you.
Pharmaceutical companies tend to spend a lot on their research and development. While this ensures medicines become better, these costs are still passed to the consumers. Because generic medications maximize the existing formulas, they can avoid this process. Companies still need to adhere to government regulations and do slight changes.