I thought if the product is out of the box you could take it for free.
Is that what you did because isn't take also called stealing?
No, a friend of mine thought it would be okay.
Your friend is wrong and you shouldn't listen to him. You just tried to justify stealing which is taking things that don't belong to you without paying. If you do that you might get thrown into jail.
I will give the item back.
I am glad that you will be giving the item back. You could have gotten in serious trouble for taking things that did not belong to you.