If we change the irreducible polynomial of the AES to someother irreducible or primitive polynomial, what effect will it have in security?
The polynomial in the AES is $x^8+x^4+x^3+x+1$ that is irreducible but not primitive. In fact, you can use an irreducible and primitive polynomial but you have to save 256 cases in computation. Another main reason for using $x^8+x^4+x^3+x+1$ in AES is mix-column state. In mix-column state we need an MDS matrix. The best optimal MDS matrix is circular MDS matrix that is constructed with the third element of finite field ($1 \,,\, \alpha \,,\, \alpha +1$). If you want to use an irreducible and primitive polynomial, you have to check that is there an optimal MDS matrix like MDS matrix of AES. I think, AES is designed such that with minimum RAM can be applied and has a proved security. In other words, in min-max problem of cryptography (security and speed) AES is an optima algorithm.
Yes, we can change the irreducible polynomial of AES to another irreducible polynomial. In doing so we have to implement a change of basis or change the polynomial for the S-Box, this may effect the security. Moreover research had been done on how to enhance the security of AES by changing the irreducible polynomial. See this paper for detailed discussion.
Hope this helps.