One way would be to use
grep -E like this:
rpm -qa | egrep -i '.*gcc.*'
This uses the supplied search string as a regular expression where the period (.) stands for any character and the asterisk (*) stands for one-or-more of those characters.
What I believe you're trying to use with
rpm -qa | grep -i *gcc* is a feature of most shells called filename globbing. This technique doesn't work with grep. It assumes that you want everything with
gcc in the string, as in your first example, without the need to specify it explicitly.
The difference between
.*gcc.* is the first is actually a syntax error with egrep, though it may not tell you. The asterisk (*) is a modifier that tells the regular expression parser that you're interested in zero-or-more of the previous character. In the first expression, there is no previous character because the single quote (') doesn't count.