Basic Question: Why define affine variety as a ringed space I am trying to learn algebraic geometry properly and am stuck on a couple of points.
1- In understanding the definition of an Affine Variety I came across a number of definitions such as zeros of polynomials or an irreducible affine algebraic set and then the definition based on structure sheaf i.e in terms of ringed spaces.
I don't quite understand how is taking ringed space different from taking an affine algebraic set together with its regular functions. Why do we need such formalism for affine case? What is the role of the structure sheaf in defining an affine variety.
2- In Daniel Perrin's book I find this sentence "The only advantage affine algebraic varieties have over affine algebraic sets is that they are intrinsic, i.e., their structure does not depend on a choice
of embedding in $k^n$". Can some one please explain this sentence. Which embedding is he talking about? How do affine algebraic sets depend on such an embedding?
I am really sorry if this question is too basic.
 A: As detailed in "What is an algebraic variety?", there are several different ways to define an algebraic variety, each more general than the last. Sheaves are very useful later on in algebraic geometry for solving a wide variety of problems, so it makes sense for us to introduce the concept with our early examples of varieties in order for us to get a handle on the concept.
It might help you to compare introducing the structure sheaf for affine algebraic varieties with how we talk about integrals. In calculus classes, we introduce integrals of nice functions like polynomials via some basic rules, and then once we get to analysis classes we introduce Riemann sums and Lebesgue integration so that we have access to the powerful theory: usually you'll have a couple examples or homework exercises proving your new theories recover all the same results as your old ones. The same sort of thing is going on here.
For question 2, one undesirable feature of considering what the author calls affine algebraic sets is that there are varieties $X$ with embeddings $f_1,f_2$ into affine space so that $f_1(X)$ is an affine algebraic set and $f_2(X)$ isn't. The most basic example is $k\setminus \{0\}$: it embeds in to $k$ in the obvious way, which isn't a variety since $k\setminus\{0\}\subset k$ isn't closed, but it also embeds in to $k^2$ via $x\mapsto (x,x^{-1})$, which is a variety (it's the zero locus of $xy-1$). Moving to a more intrinsic definition of variety avoids such issues.

Added in response to the comment asking for why we need the structue sheaf:
One motivational principle of algebraic geometry is that we can do a lot with a ring if we know it's the ring of functions on a manifold (or some other geometric object) - for instance, if the geometric object is disconnected, then we can decompose our ring as the direct product of the rings which are the functions on the connected components, or we can detect compactness of our manifold by finding a maximal ideal which doesn't come from evaluation at a point. It would be a natural question to try and apply this insight to a general ring: if you give me a ring $R$, what's the geometric object that this is the ring of functions on? The answer is the scheme $\operatorname{Spec} R$ (the spectrum of $R$).
When we study schemes, we have a lot of local data to carry around: we have regular functions on every open set, and we want an intrinsic way to package this all up. The structure sheaf gives us a way to do all of this efficiently - it keeps track of all the data for us. In some sense, most sheaves on varieties and schemes you want to discuss will be built (at least locally) out of copies of the structure sheaf - this is exactly the condition of being quasi-coherent. So studying sheaves means we need to know about the structure sheaf.
As for what problems you can solve via methods which become available after having access to sheaves, the big tool is sheaf cohomology. This does lots of wonderful things for us: most results involving cohomology from algebraic topology have versions in algebraic geometry where we use sheaf cohomology instead of singular/simplicial/cellular cohomology. For instance, as wacky as the Zariski topology might seem, we still get Serre duality (something that looks like Poincare duality) for smooth varieties over arbitrary fields, we have Kunneth formulas, we have characteristic classes, and we can count special curves or points (a very geometric thing to do!) via sheaf cohomology.
