How do landing gear retracting into the wing affect performance when deployed?
There are two main geometrical characteristics that affect the airflow in the situation mentioned. From one side you have a cylinder with wheels at the end; on the other side during the transition you have an open cavity.

Let's talk about the first one. You actually have a cylinder flying perpendicular to the air speed. This is kind of canonical problem in fluid dynamics, there is a lot of literature about this problem, but to explain the effect I would like to take a simple example that I took from the website, the infinite 2D cylinder. For that, I include this picture of flow over a cylinder:

  

Note for fluid dynamics experts: This is not relevant if Reynolds Number (Re) is around 10,000, but for understanding the concept is good enough.

So, imagine that we are cutting landing gear perpendicular to its length and we visualize the flow.

What do we see?

Two main things....


Looking at the flow lines, they are almost not affected at 3-4 diameters of distance from the cylinder perpendicular to the flow direction there is a very local influence of the existence of the landing gear.


However we see that down the flow there is a big influence with the creation of chaotic structures. That is creating a big increase in drag downstream of the landing gear and any surface behind.



Basically... low influence on the red direction and significant influence on blue. Answering your question, influences the wing in a local area.



The influence anyhow is negative on the lift, as the flow is accelerated locally, reducing the static pressure below the wing, having a lift reduction, but is a local effect. This also have an influence on the wing lift distribution and a small effect on drag... lower than the one directly produced by the landing gear itself.

Now.... the cavities, they have a bigger influence, firstly because they have bigger extension parallel to the airplane surface (the landing gear goes perpendicular to the airplane the cavity goes along the surface). Secondly, their flow behaviour is different, goes in and outside the cavity. I found this web page very good on this, but basically the flow behaviour is like these image:



I found several flows similar to the second one, but depends on the airplane. You can see that flow will enter and go outside and will have a big influence.

Finally, the biggest influence is found when the airplane is deploying or retracting the landing gears when you have changing conditions, difficult to predict and affecting the airplane dynamics. Usually you can notice it when landing or taking off, when landing gear is deployed you fell significant vibration on the airplane.

Concerning your questions:


How does the landing gear affect aerodynamics when deployed and when deploying?


There is a significant drag increase, slightly the lift, but also creates some unsteady behaviour affecting overall airplane mechanics creating vibrations (anyhow, nothing not already taken into account).


Is it different for aircraft whose landing gear do not retract into the wing?


I understand that you refer to airplane with non retractable landing gear. The effect is similar but usually the configuration tries to avoid  having the landing gear close to the wing, as finally they don't need to retract them back.


Does this modify performance critical when taking off or landing such as stall speed, optimal climb speed?


Well, stall speed is usually defined by wing lift curve, and not so much affected by the landing gear. Usually the limitation is on the upper side due to separation.
Climb speed is basically engine thrust minus drag, the drag increases the climb speed is lower. That's why airplanes retract the landing gear as soon as possible.